package com.github.freewu.mvp.view.status;

import android.content.Context;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.widget.FrameLayout;
import android.widget.TextView;

import com.lqkj.commons.R;

/**
 * Created by free on 16-9-9.
 */
public class ErrorView extends FrameLayout{

    private TextView prompt;

    public ErrorView(Context context) {
        super(context);

        init();
    }

    public ErrorView(Context context, AttributeSet attrs) {
        super(context, attrs);

        init();
    }

    public ErrorView(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);

        init();
    }
    private void init(){
        LayoutInflater.from(getContext()).inflate(R.layout.error_layout,this);

        prompt=(TextView)findViewById(R.id.prompt);

        prompt.setText("数据错误");
    }

    public TextView getPrompt() {
        return prompt;
    }

    /**
     * 设置错误页面显示文字
     * @param string
     */
    public void setErrorText(String string){
        if (prompt!=null && !TextUtils.isEmpty(string)){
           prompt.setText(string);
        }
    }
}
